// <!-- 设置搜索框点击清空 -->
var searchCon = document.querySelector('.search-con');
searchCon.onfocus = function() {
	searchCon.value = '';
}
searchCon.onblur = function() {
	if (searchCon.value == '') {
		searchCon.value = 'Five Plus';
	}
}
// 首页悬浮
$(function() {


	$('.content-a').mousemove(function() {
		var ind = $('.content-a').index($(this));
		$('.content-a').css("color", "black");
		$(this).css("color", "red");
	})
	// 热销榜
	var darx = rxDate.jsrx;
	var str = '';
	darx.forEach(function(v, i) {
		str += `
			<li class="box-li">
				<div class="box-li-top">
					<a class="box-li-top-a" href="#1"><img class="imgb"src="${v.url}"alt=""></a>
				</div>
				<div class="box-li-bottmo">
					<span class="sp">${v.id}</span>
					<a class="box-li-bottmo-a" href="#1">WMNS Air Jordan 13 aj13 鳄鱼皮纹理 女鞋篮球鞋 - AQ1757 004</a>
					<span class="sp1">${v.money}</span>
				</div>
			</li>
		`;
	})
	$('.box-ul:first').append(str)

	// 促销榜
	var dacx = cxDate.cxjs;
	str = '';
	dacx.forEach(function(v) {
		str += `
		<li class="box-li">
			<div class="box-li-top">
				<a class="box-li-top-a" href="#1"><img class="imgb"src="${v.url}"alt=""></a>
			</div>
			<div class="box-li-bottmo">
				<span class="sp">${v.id}</span>
				<a class="box-li-bottmo-a" href="#1">${v.name}</a>
				<span class="sp1">${v.money}</span>
			</div>
		</li>
		`;
	})
	$('.box-ul:last').append(str);

	// 渲染今日推荐
	var dajs = shoeDate.json;
	str = '';
	dajs.forEach(function(v) {
		str += `
			<li class="boxbb-li">
				<div class="box-li-top">
					<a class="box-li-top-a" href="#1"><img class="imgb"src="${v.url}"alt=""></a>
				</div>
				<div class="boxbb-li-bottmo">
					<a class="boxbb-li-bottmo-a" href="#1">${v.name}</a>
					<p class="sp1">${v.money}</p>
				</div>
			</li>
		`;
	})
	$('.boxbb-ul').append(str)
	// 设置鼠标悬停<!-- 热销榜 -->
	$('.box-left-a').mousemove(function() {
		var index = $('.box-left-a').index($(this));
		$('.box-left-a').css("color", "black");
		$(this).css("color", "red");
		$(".box-ul").css("opacity", "0")
		$(".box-ul").eq(index).css({"transition": "all 0.6s linear","opacity": "1"});
	})

	var lljs = llDate.lljs;
	str = '';
	lljs.forEach(function(v) {
		str += `
			<li class="boxcc-li">
				<div class="boxcc-li-top">
					<a class="boxcc-li-top-a" href="#1"><img class="imgb"src="${v.url}"alt=""></a>
				</div>
				<div class="boxcc-li-bottmo">
					<p class="sp2">${v.money}</p>
					<a class="boxcc-li-bottmo-a" href="#1">${v.name}</a>
					<a class="a2"href="#1">${v.details}</a>
				</div>
			</li>
		`;
	})
	$('.boxcc-ul').append(str)


	$('.boxcc').mouseenter(function() {
		$('.prev').show()
		$('.next').show()
		$('.boxa-div-aa').show()
	})
	$('.boxcc').mouseleave(function() {
		$('.prev').hide();
		$('.next').hide();
	})
	$('.boxa-div-aa:first').click(function() {
		$('.boxa-li').css('transform', 'translateX(0px)')
	})
	$('.boxa-div-aa:last').click(function() {
		$('.boxa-li').css('transform', 'translateX(-1184px)')
	})




	$('.prev').click(function() {
		$('.boxcc-ul').css('transform', 'translateX(0px)')
	})
	$('.next').click(function() {
		$('.boxcc-ul').css('transform', 'translateX(-1195px)')
	})











	LiftEffect({
		"control1": ".lift-nav", //侧栏电梯的容器
		"control2": ".lift", //需要遍历的电梯的父元素
		"target": [".t1", ".t2", ".t3", ".t4", ".t5", ".t6"], //监听的内容，注意一定要从小到大输入
		"current": "current" //选中的样式
	});

})



function LiftEffect(json){

var array=[];

for(var i =0; i<json.target.length;i++){
	var t = $(json.target[i]).offset().top;
	// console.log(t);
	array.push(t);

}

function Selected(index){
	$(json.control2).children().eq(index).addClass(json.current).siblings().removeClass(json.current);
}
$(window).on("scroll",Check);
function Check(){
	var wst = $(window).scrollTop();
	console.log(wst);
	if(wst >= $(json.target[0]).offset().top-0){
		$(json.control1).fadeIn(500);
	}else{
		$(json.control1).fadeOut(200);
	}
	var key =0;
	var flag = true;
	for(var i =0; i<array.length; i++){
		key++;
		if(flag){

			if(wst >= array[array.length-key]-600){
				var index = array.length-key;
				flag = false;
			}else{
				flag=true;
			}
			
		}
	}
	Selected(index);
}

$(json.control2).children().on("click",function(){

		$(window).off("scroll");
		var index = $(this).index();
		Selected(index);

		
		var flag = true;
		for(var i =0; i<array.length; i++){
		
			if(flag){
	
				if(index == i){
					$("html,body").stop().animate({
						"scrollTop": array[i]-500
					},500,function(){
						$(window).on("scroll",Check);
					});
					flag = false;
				}else{
					flag=true;
				}
				
			}
		}
		
});



}














